﻿#ifndef _SPATIALINTERFACE_RASTERDATASET_H
#define _SPATIALINTERFACE_RASTERDATASET_H

#include "udatabase/interface/idataset.h"
#include "udatabase/progressinfo.h"
#include "udatabase/dll_cfg.h"
#include "kernel/string_def.h"
#include "kernel/OgreDataStream.h"
#include "kernel/xml.h"
#include "drawing/interface/irasterblock.h"

namespace FD
{
	namespace Utility
	{
		namespace DB
		{
			namespace Interface
			{
				///<summary>
				/// 栅格数据集基类
				/// </summary>
				class FD_DB_Export IRasterDataset : public FD::Utility::DB::Interface::IDataset
				{
				public:
					virtual ~IRasterDataset();
				public:
					///<summary>
					///获取栅格数据集的地理矩形
					///</summary>
					/// <param name="dfUpleftX">左上角X坐标</param>
					/// <param name="dfUpleftY">左上角Y坐标</param>
					/// <param name="dfDownRightX">左上角X坐标</param>
					/// <param name="dfDownRightY">左上角Y坐标</param>

					virtual void getRasterRect( double &dfUpleftX, double &dfUpleftY, double&dfDownRightX,
						double&dfDownRightY)const;

					///<summary>
					///获取栅格之宽度
					///</summary>
					virtual const INT32 getRasterWidth()const;
					///<summary>
					///获取栅格之高度
					///</summary>
					virtual const INT32 getRasterHeight()const;

					///<summary>
					///获取波段数
					///</summary>
					virtual const INT32 getBandCount()const;
					///<summary>
					///获取栅格数据类型
					///</summary>
					virtual uint64 getRasterDataType()const;
					///<summary>
					///获取数据集的空间参考
					///</summary>
					/// <param name="strWKT">空间参考的字符串表示</param>
					virtual void getSpatialReferenceWkt( String&strWKT)const;
					///<summary>
					///设置栅格数据集的空间参考
					///</summary>
					/// <param name="strWKT">空间参考的WKT字符串描述</param>
					virtual void setSpatialReference( const String&strWKT);
					///<summary>
					///读取栅格数据
					///如果栅格对象设置了地理参数，则根据地理范围读取数据（行列号可全部设置为0），
					///否则，根据行列号范围读取
					///</summary>
					/// <param name="pDstRaster">目标栅格块对象</param>
					/// <param name="upRow">左上角像素行号（从0开始）</param>
					/// <param name="leftCol">左上角像素列号（从0开始）</param>
					/// <param name="downRow">右下角行号</param>
					/// <param name="rightCol">右下角列号</param>
					virtual bool read(FD::Kernel::Drawing::Interface::IRasterBlock* pDstRaster,
						UINT32 upRow, UINT32 leftCol, 
						UINT32 downRow, UINT32 rightCol);
					///<summary>
					///将栅格块对象中的数据写入栅格数据集
					///如果栅格对象设置了地理参数，则根据地理范围写入数据集（行列号可全部设置为0），
					///否则，根据行列号范围写入
					///</summary>
					/// <param name="pSrcRaster">待写入的栅格块对象</param>
					/// <param name="upRow">左上角像素行号（从0开始）</param>
					/// <param name="leftCol">左上角像素列号（从0开始）</param>
					/// <param name="downRow">右下角行号</param>
					/// <param name="rightCol">右下角列号</param>
					virtual bool write(const FD::Kernel::Drawing::Interface::IRasterBlock* pSrcRaster,
						UINT32 upRow, UINT32 leftCol, 
						UINT32 downRow, UINT32 rightCol);
					/// <summary>
					/// 从栅格数据集中读取一块指定坐标系、大小、分辨率以及左上角坐标的数据
					/// </summary>
					/// <param name="spatialRef">目标坐标系的WKT字符串</param>
					/// <param name="lefttopX">目标数据的左上角X坐标</param>
					/// <param name="lefttopY">目标数据的左上角Y坐标</param>
					/// <param name="resolutionX">X方向分辨率</param>
					/// <param name="resolutionY">Y方向分辨率</param>
					/// <param name="xSize">X方向大小（宽度）</param>
					/// <param name="ySize">Y方向大小（高度）</param>
					/// <param name="nBands">波段数</param>
					/// <param name="pBandIndex">波段索引数组</param>
					/// <param name="pBuffer">存放读取数据的缓冲区，缓冲区大小为宽度 * 高度 * 像素占字节数 * 波段数</param>
					virtual void read( String& strWKT, 
						double lefttopX, 
						double lefttopY, 
						double resolutionX, 
						double resolutionY,
						INT32 xSize, 
						INT32 ySize, 
						BYTE* pBuffer);
					///<summary>
					///创建金字塔影像,img格式影像要求打开时候为Update，否则
					///创建金子塔会失败 
					///</summary>
					/// <param name="ibandCount">波段数</param>
					/// <param name="piBandIndex">波段索引</param>
					/// <param name="nLevelCount">金字塔级别数</param>
					/// <param name="piLevelIndex">金字塔级别索引</param>
					/// <param name="pfnProgress">函数指针</param>
					/// <param name="pDataProgress">进度相关数据</param>
					/// <returns>1,成功 0，失败</returns>
					virtual bool buildOverViews(INT32 ibandCount, INT32 *piBandIndex,
						INT32 nLevelCount, INT32 *piLevelIndex,
						FD::Utility::DB::CProgressInfo *pDataProgress);
				protected:
					IRasterDataset();
				private:
					IRasterDataset& operator=(const IRasterDataset&);
					IRasterDataset(IRasterDataset&);
				};
			}
		}
	}
}

#endif
